package org.stars.daostars;

import static org.junit.Assert.assertTrue;

import static org.junit.Assert.assertTrue;

import org.stars.daostars.core.DaoStars;
import org.stars.daostars.core.Profile;
import org.stars.daostars.loader.xml.DaoStarsXmlLoader;
import org.stars.daostars.sqlmapper.SqlMapper;
import org.stars.daostars.sqlmapper.loader.xml.DaoLoader;
import org.stars.util.StringUtility;

import org.junit.Test;

public class DaoStarsLoader {
	@Test
	public void test() throws Exception
	{
		DaoStarsXmlLoader loader=new DaoStarsXmlLoader();
		int res=loader.loadFile("src/test/resources/WEB-INF/websecurity/daostars1.xml");
		// assert: file caricato correttamente
		assertTrue(res==0);
		
		Profile profile=DaoStars.getInstance().getActiveProfile();
		
		assertTrue("wsx".equalsIgnoreCase(profile.getName()));
		assertTrue("wsx".equalsIgnoreCase(profile.getDefaultConnectionName()));
		
		System.out.println("Esecuzione terminata correttamente");
	}
	
	@Test
	public void testFileNotFound() throws Exception
	{
		DaoStarsXmlLoader loader=new DaoStarsXmlLoader();
		int res=loader.loadFile("src/test/resources/WEB-INF/websecurity/daostars.xml.nopresent");
		// assert: file caricato correttamente
		assertTrue(res==1);
		System.out.println("Esecuzione terminata correttamente");
	}

}
